a=-748;b=700;r1=892;r2=1280;
r1=r1+20;
r2=r2-20;
a_inner = a;   
a_outer = a;
b_inner = b;
b_outer = b;
% str_read = 'F:\点火PIV实验\处理结果\冷态8-286不同高度\60mm.bmp';
str_read = 'F:\毕业设计\毕设结题\同态&均衡化\图片\0371.tif';
rgb=imread(str_read);   

[m,n,k]=size(rgb); %rgb 例：图像的尺寸m * n * k  == 612 * 1537 * 3  uint8

%把裁掉边框的部分放在rgb1中
% PIV_a = m-37;
% PIV_b = n-25;
% A=zeros(PIV_a,PIV_b);
% A=uint16(A);
% % rgb1=cat(3,A,A,A);
% for i=1:PIV_a
%     for j=1:PIV_b
%         rgb1(i,j,:)=rgb(i+16,j+11,:);%裁掉边框的部分
%     end
% end

row = 552;col = 1392;   %默认以高通图片尺寸为全局
% rgb1= imresize(rgb1,[row col]);
rgb1=rgb;

%% 两侧
 %rgb1 边界涂白，消除之前的处理痕迹
check = 1;
for i=1:row
    for j=1:col  
        check= (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if check<0
% %             rgb1(i,j,1)=255;
% %             rgb1(i,j,2)=255;
% %             rgb1(i,j,3)=255;
            rgb1(i,j)=200000;
        end
        check= (i-a_outer).^2+(j-b_outer).^2-r2^2;
        if check>0
%             rgb1(i,j,1)=255;
%             rgb1(i,j,2)=255;
%             rgb1(i,j,3)=255;
            rgb1(i,j)=200000;
        end
    end
end
%% 边框
%rgb1 内外壁涂黑
r1_new=r1;
r2_new=r2;
a1=zeros(row,col);
for i=1:row
    for j=1:col
        a1(i,j)= (i-a_inner).^2+(j-b_inner).^2-r1_new^2;
        if (a1(i,j)<1500) && (a1(i,j)>-1500) %649 * 5pixels
%             rgb1(i,j,1)=0;
%             rgb1(i,j,2)=0;
%             rgb1(i,j,3)=0;
            rgb1(i,j)=0;
        end
        a1(i,j)= (i-a_outer).^2+(j-b_outer).^2-r2_new^2;
        if ( a1(i,j)<2000) && ( a1(i,j)>-2000 )
%             rgb1(i,j,1)=0;
%             rgb1(i,j,2)=0;
%             rgb1(i,j,3)=0;
            rgb1(i,j)=0;
        end
    end
end

%rgb1 上方的涂黑
for i=1:2
    for j=1:col %214 174
        a1(i,j)= (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if a1(i,j)>=0
%             rgb1(i,j,1)=0;
%             rgb1(i,j,2)=0;
%             rgb1(i,j,3)=0;
            rgb1(i,j)=0;
        end
    end
end
%rgb1 左右两边的涂黑
for i=1:row %284  310
    for j=1:2
        check1 = (i-a_outer).^2+(j-b_outer).^2-r2^2;
        check2 = (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if check1 <= 0 && check2>=0
%             rgb1(i,j,1)=0;
%             rgb1(i,j,2)=0;
%             rgb1(i,j,3)=0;
            rgb1(i,j)=0;
        end

    end
end

for i=1:row %284  310
    for j=col-1:col
        check1 = (i-a_outer).^2+(j-b_outer).^2-r2^2;
        check2 = (i-a_inner).^2+(j-b_inner).^2-r1^2;
        if check1 <= 0 && check2>=0
%             rgb1(i,j,1)=0;
%             rgb1(i,j,2)=0;
%             rgb1(i,j,3)=0;
            rgb1(i,j)=0;
        end

    end
end

% imshow(rgb1);
imwrite(rgb1,str_read)